#ifndef DDC_MAIN_H_INCLUDED
#define DDC_MAIN_H_INCLUDED

#include <string>
#include <vector>

#include "SDL.h"

#include "ddc_internal.h"
#include "ddc_obj.h"

class DodocoInitError {
    std::string info;

public:
    DodocoInitError(std::string info): info(info) {}
};

class Dodoco {
    Dodoco(int windowWidth, int windowHeight, int maxFPS);

    static Dodoco *_dodoco;

    DDC_Scene *_currentScene = nullptr;
    bool _sceneSwitched = false;
    DDC_Scene *_sceneToSwitch = nullptr;

    std::vector<DDC_Scene*> _scenes;

    int _windowHeight;
    int _windowWidth;
    int _maxFPS;

    void _RenderScreen();
    int _RunScene(DDC_Scene *scene);

public:
    static Dodoco* GetDodocoWithInit(int windowWidth, int windowHeight, int maxFPS = 60);
    static Dodoco* GetDodoco();

    DDC_Scene *NewScene(std::string sceneName, int *outSeneIndex);
    DDC_Scene *NewScene(std::string sceneName);
    int GetSceneIndex(std::string sceneName);
    DDC_Scene *GetScene(int index);
    int SwitchScene(int sceneIndex);
    int RemoveScene(int index);

    void GetWindowSize(int *width, int *height) {
        SDL_GetWindowSize(__gDodocoMainWindow, width, height);
    }

    SDL_Surface *GetDodocoWindowSurface() {
        return __gDodocoMainSurface;
    }

    SDL_Renderer *GetDodocoRenderer() {
        return __gDodocoMainRenderer;
    }

    DDC_Scene *GetCurrentScene() {
        return _currentScene;
    }

    bool doRenderClear = true;

    int Run(DDC_Scene *initScene);
};

#endif // DDC_MAIN_H_INCLUDED
